<%= semantic_form_for [:admin, @audit_work_order] do |f| %>
  <%= f.semantic_errors %>

  <% reimbursement = f.object.reimbursement || (params[:reimbursement_id] ? Reimbursement.find_by(id: params[:reimbursement_id]) : nil) %>

  <div class="tabs">
    <div class="tab-content" id="tab-basic-info">
      <h3>基本信息</h3>
      <%= f.inputs '工单详情' do %>
        <% if reimbursement %>
          <%= render 'admin/reimbursements/reimbursement_display', reimbursement: reimbursement %>
          <%= f.input :reimbursement_id, as: :hidden, input_html: { value: reimbursement.id } %>
        <% elsif f.object.reimbursement %>
          <%= f.input :reimbursement_invoice_number, label: '报销单号', input_html: { value: f.object.reimbursement.invoice_number, readonly: true, disabled: true } %>
        <% end %>
        <%= f.input :status, input_html: { readonly: true, disabled: true }, label: '工单状态' if f.object.persisted? %>
      <% end %>

      <!-- 费用明细选择 -->
      <% if reimbursement %>
        <%= render 'admin/shared/fee_details_selection', work_order: f.object, reimbursement: reimbursement %>
      <% else %>
        <%= f.inputs '费用明细' do %>
          <p>无法加载费用明细，未关联有效的报销单。</p>
        <% end %>
      <% end %>

      <%= f.inputs '处理与反馈', id: 'processing-feedback-section' do %>
        <div class="input radio_buttons">
          <fieldset class="choices">
            <legend class="label">处理意见</legend>
            <ol class="choices-group">
              <li class="choice">
                <label for="audit_work_order_processing_opinion_可以通过">
                  <input type="radio" id="audit_work_order_processing_opinion_可以通过" name="audit_work_order[processing_opinion]" value="可以通过" class="processing-opinion-radio">
                  可以通过
                </label>
              </li>
              <li class="choice">
                <label for="audit_work_order_processing_opinion_无法通过">
                  <input type="radio" id="audit_work_order_processing_opinion_无法通过" name="audit_work_order[processing_opinion]" value="无法通过" class="processing-opinion-radio">
                  无法通过
                </label>
              </li>
            </ol>
          </fieldset>
        </div>
        
        <!-- 审核意见输入框 -->
        <%= f.input :audit_comment, label: "审核意见",
                input_html: { id: 'audit_comment_field', class: 'audit-comment' } %>
      <% end %>
    </div>
  </div>
  
  <div class="form-actions">
    <%= f.actions do %>
      <%= f.action :submit, as: :button, label: "提交", button_html: { class: "button" } %>
      <%= f.action :cancel, as: :link %>
    <% end %>
  </div>
<% end %>

<%= stylesheet_link_tag 'work_order_form', media: 'all' %>
<%= javascript_include_tag 'work_order_form' %>